<!-- 输出到页面中 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遍历对象属性</title>
</head>
<body>
    <div id="output"></div>
    <script>
       // 步骤a: 声明一个空数组对象books
var books = {};

// 步骤b: 给数组中添加属性
books.title1 = "《JavaScript前端开发案例教程》";
books.title2 = "《Node.js核心基础教程》";
books.title3 = "《HTML5移动Web开发》";

// 步骤c: 使用for…in循环输出books的属性
for (var prop in books) {
    if (books.hasOwnProperty(prop)) {
        console.log(prop + ": " + books[prop]);
    }
}

    </script>
</body>
</html>
